package org.xdj.blue.dubbo.service;

import java.util.Map;

import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import org.springframework.stereotype.Service;
import org.xdj.blue.dubbo.entity.User;
import org.xdj.blue.dubbo.tools.Utill;

import com.alibaba.dubbo.rpc.protocol.rest.support.ContentType;

@Path("/userService")
@Consumes({MediaType.APPLICATION_JSON})
@Produces({ ContentType.APPLICATION_JSON_UTF_8, ContentType.TEXT_XML_UTF_8 })
@Service("userService")
public class UserServiceImpl implements UserService {

	@POST
	@Path("/getName")
	public String getName(String userId) {
		System.out.println("--userId:"+userId+ "--");
		String value = Utill.fromJson(userId, Map.class).get("userId").toString();
		User user = getUser();
		if(!value.equals(user.getUserId())){
			user.setUserId("1002");
			user.setUserName("大张伟");
		}
		return Utill.toJson(user) ;
	}
	
	public User getUser(){
		User user = new User("李华");
		user .setId(1001);
		user.setUserId("1001");
		user.setAge(23);
		user.setSex("男");
		return user;
	}

}
